package com.yugao.fintech.antelope.mps.controller;

import com.github.yitter.idgen.YitIdHelper;
import com.yugao.fintech.antelope.base.security.annotation.InnerAuth;
import com.yugao.fintech.antelope.mps.api.model.rqrs.MsgPushParam;
import com.yugao.fintech.antelope.mps.core.propcess.MsgPushProcess;
import com.yugao.fintech.framework.core.response.Resp;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/msgPush")
@Api(tags = "消息推送")
public class MsgPushController {
    @Autowired
    private MsgPushProcess msgPushHandler;

    /**
     * 需要做防刷操作, 只能是内网调用
     */
    @PostMapping("/")
    @InnerAuth
    public Resp<?> push(@RequestBody @Validated MsgPushParam msgPush) {
        msgPush.setHistoryId(null);
        msgPushHandler.push(msgPush, String.valueOf(YitIdHelper.nextId()));
        return Resp.ok();
    }
}
